package com.qianfeng.smartdevices.dto;




import com.fasterxml.jackson.annotation.JsonInclude;


@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class R {
    private String msg;
    private int code;
    private Object result;


    public static R setOK() {
        return setOK(null);
    }

    public static R setOK(Object data) {
        R result = new R();
        result.setMsg("success");
        result.setCode(ResultCode.SUCCESS);
        result.setResult(data);
        return result;
    }

    public static R SetError(Object data) {
        return SetError(data, "fail", ResultCode.ERROR);
    }

    public static R SetError(Object data, String msg, int code) {
        R result = new R();
        result.setMsg(msg);
        result.setCode(code);
        result.setResult(data);
        return result;
    }


    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getResult() {
        return result;
    }

    public void setResult(Object result) {
        this.result = result;
    }
}
